//
//  DepartmentBriefContentView.swift
//  PropertyCommunity
//
//  Created by benwang on 2021/7/4.
//

import UIKit

class DepartmentBriefContentView: UIView {
  @IBOutlet weak var titleLabel: UILabel!
  @IBOutlet weak var bodyLabel: UILabel!

  override func awakeFromNib() {
    super.awakeFromNib()
    titleLabel.font = .designKit.title3
  }

  func update(text: String) -> CGFloat {

    bodyLabel.text = text

    var height: CGFloat = 83
    let maxWidth = UIScreen.main.bounds.width - 30

    height += text.boundingRect(
      with: CGSize(width: maxWidth, height: .infinity),
      options: .usesLineFragmentOrigin,
      attributes: [
        .font: UIFont.systemFont(ofSize: 16)
      ],
      context: nil).height
    return height
  }


    /*
    // Only override draw() if you perform custom drawing.
    // An empty implementation adversely affects performance during animation.
    override func draw(_ rect: CGRect) {
        // Drawing code
    }
    */

}
